package com.test.amqp;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitTopicConfig {

    public final static String TOPIC_NAME = "root-topic";

    @Bean
    TopicExchange topicExchange() {
        return new TopicExchange(TOPIC_NAME, true, false);
    }

    @Bean
    Queue top1(){
        return new Queue("topic1");
    }
    @Bean
    Queue top2(){
        return new Queue("topic2");
    }
    @Bean
    Queue top3(){
        return new Queue("topic3");
    }

    @Bean
    Binding topic1Binding(){
        return BindingBuilder.bind(top1()).to(topicExchange()).with("topic1.#");
    }

    @Bean
    Binding topic2Binding(){
        return BindingBuilder.bind(top2()).to(topicExchange()).with("topic2.#");
    }

    @Bean
    Binding topic3Binding(){
        return BindingBuilder.bind(top3()).to(topicExchange()).with("topic3.#");
    }
}
